
<style>
    .file-box {
        position: relative;
        display: inline-block;
    }
    .file-box img {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        position: absolute;
        top: -30px;
        left: 0;
        display: inline-block;
        border: none;
    }
    .file-box .txt,.file-box .file {
        width: 70px;
        height: 36px;
        position: absolute;
        top: -20px;
        left: 100px;
        text-align: center;
    }
</style>





<div class="admin-biaogelist">

    <div class="listbiaoti am-cf">
        <ul class="am-icon-flag on"> 拼多多任务发布</ul>

        <dl class="am-icon-home" style="float: right;">当前位置： 首页 > <a href="#">拼多多任务发布</a></dl>
        <!--<dl>
          <button type="button" class="am-btn am-btn-danger am-round am-btn-xs am-icon-plus" > 补充线订单</button>
        </dl>-->
        <!--这里打开的是新页面-->
    </div>

    <div class="fbneirong">
        <form class="am-form jdtask">
            <div class="am-form-group am-cf">
                <div class="zuo">商品链接：</div>
                <div class="you">
                    <input type="text" class="am-input-sm"  name="link"   style="width: 600px;" placeholder="请输入链接">
                    <button    id="updata" class="am-btn am-btn-secondary am-radius">更新</button>
                </div>

            </div>
            <div class="am-form-group am-cf">
                <div class="zuo">商品名称：</div>
                <div class="you">
                    <input type="text"   name="goods_name" class="am-input-sm" id="doc-ipt-email-1"  style="width: 500px;"  placeholder="请输入商品名称">
                </div>
            </div>

            <div class="am-form-group am-cf">
                <div class="zuo">店铺名称：</div>
                <div class="you">
                    <input type="text"   name="shop_name" class="am-input-sm" id="doc-ipt-email-1"  style="width: 500px;" placeholder="请输入店铺名称">
                </div>
            </div>

            <div class="am-form-group am-cf">
                <div class="zuo">客单价：</div>
                <div class="zuo">
                    <input type="text"   name="price" class="am-input-sm" id="doc-ipt-email-1" placeholder="请输入客单价">
                </div>


            </div>

            <div class="am-form-group am-cf">

                <div class="zuo">开团价格：</div>
                <div class="zuo">
                    <input type="text"   name="single_price" class="am-input-sm" id="doc-ipt-email-1" placeholder="请输入开团价格">
                </div>

                <div class="zuo">拼团价格：</div>
                <div class="zuo">
                    <input type="text"   name="group_price" class="am-input-sm" id="doc-ipt-email-1" placeholder="请输入拼团价格">
                </div>


                <div class="zuo">搜索关键字：</div>
                <div class="zuo">
                    <input type="text"   name="keyword" class="am-input-sm" id="doc-ipt-email-1" placeholder="请输入关键字" style="width: 400px;">
                </div>
            </div>


            <div class="am-form-group am-cf">
                <div class="zuo">付款价格：</div>
                <div class="zuo">
                    <input type="text"   name="pay_price" class="am-input-sm" id="doc-ipt-email-1" placeholder="请输入付款价格">
                </div>
                <div class="zuo">任务单量：</div>
                <div class="zuo">
                    <input type="text"   name="number" class="am-input-sm" id="doc-ipt-email-1" placeholder="请输入任务单量">
                </div>

                <div class="zuo">每单数量：</div>
                <div class="zuo">
                    <input type="text"   name="each_single" class="am-input-sm" id="doc-ipt-email-1" placeholder="请输入每单数量">
                </div>


            </div>


            <div class="am-form-group am-cf">
                <div class="zuo">购买类型选择：</div>
                <div class="you" style="margin-top: 4px;">
                    <label class="am-radio-inline">
                        <input type="radio"  value="1" name="pay_type"> 全部开团
                    </label>
                    <label class="am-radio-inline">
                        <input type="radio" value="2" name="pay_type"> 单独购买
                    </label>
                    <label class="am-radio-inline">
                        <input type="radio" value="3" name="pay_type"> 优先参团
                    </label>


            </div>
            </div>

            <div class="am-form-group am-cf">
                <div class="zuo">备注说明：</div>
                <div class="you">
                    <input type="text"   name="remarks" class="am-input-sm" id="doc-ipt-email-1" placeholder="请输入备注">
                </div>
            </div>
            <div class="am-form-group am-cf">
                <div class="zuo">SKU：</div>
                <div class="you">
                    <input type="text"   name="sku" class="am-input-sm" id="doc-ipt-email-1" placeholder="请输入备注">
                </div>
            </div>

            <div class="am-form-group am-cf">
                <div class="zuo">主图上传：</div>
                <div class="you" style="height: 45px;">



                    <input type="file" name="uploadFile" id="upload_file" style="margin-bottom:10px;">
                    <input type="button" id="uploadPicButton" value="上传" onclick="uploadPic()">

                     <p class="am-form-help"  style="position: absolute;  left: 400px;  top: 440px;">
                         <img src=""  class="picshow"   style="display: none"  width="100px;" height="100px;"></p>


                    <input type="hidden"  name="pic" value="">

                </div>
            </div>


            <div class="am-form-group am-cf" style="margin-left: 100px; margin-top: 50px;">
                <div class="zuo">任务所需本金：<span class="needmoney">0</span></div>
                <div class="zuo">任务所需金币：<span class="needgold">0</span></div>
            </div>



            <div class="am-form-group am-cf">
                <div class="you" style="margin-left: 11%;">
                    <div    id="fabu" class="am-btn am-btn-secondary am-radius">发布任务</div>

                </div>
            </div>
        </form>




    </div>


    <script>

        var picurl="";
        var picpath="";

        function uploadPic(){
            var pic = $('#upload_file')[0].files[0];
            var fd = new FormData();
            fd.append('uploadFile', pic);


            var url = "<?php echo base_url(); ?>/Business/uppic";

            $.ajax({
                url:url,
                type:"post",
                dataType:"json",
                // Form数据
                data: fd,
                cache: false,
                contentType: false,
                processData: false,
                success:function(data){
                    if(data.code==0){
                        $(".picshow").attr("src",data.url)
                        $(".picshow").show();
                        $("input[name=pic]").val(data.url);
                        picpath=data.path;
                        return;
                    }
                    layer.msg(data.msg);

                }

            });
        }

    </script>



    <script>



        var on_request=false;
        var type=1;
        var page=1;

        $("#fabu").click(function () {
            fabu()
        });

        $("input[name='price']").change(function () {
            var value=$(this).val();
            $("input[name='pay_price']").val(value);
            $("input[name='single_price']").val(value);
            $("input[name='group_price']").val(value);
        });

       /* $("input[name='goods_name']").change(function () {
            var value=$(this).val();
            $("input[name='keyword']").val(value);
        });*/

    /*    $("input[name='keyword']").change(function () {
            var value=$(this).val();
            $("input[name='goods_name']").val(value);
        });*/



        function fabu() {
            if (on_request) {
                return;
            }
            var url = "<?php echo base_url(); ?>/Business/SendPddTask";
            var postdata = {};
            var link=$("input[name='link']").val();
            var goods_name=$("input[name='goods_name']").val();
            var shop_name=$("input[name='shop_name']").val();
            var price=$("input[name='price']").val();
            var pay_price=$("input[name='pay_price']").val();

            var number=$("input[name='number']").val();
            var each_single=$("input[name='each_single']").val();
            var keyword=$("input[name='keyword']").val();
          //  var coupon=$("input[name='coupon']").val();
            var sku=$("input[name='sku']").val();
            var remarks=$("input[name='remarks']").val();
            var pay_type=$("input[name='pay_type']:checked").val();
            var single_price=$("input[name='single_price']").val();
            var group_price=$("input[name='group_price']").val();




            postdata['link'] = link;
            postdata['goods_name'] = goods_name;
            postdata['shop_name'] = shop_name;
            postdata['price'] = price;
            postdata['pay_price'] = pay_price;
            postdata['number'] = number;
            postdata['each_single'] = each_single;
            postdata['keyword'] = keyword;
          //  postdata['coupon'] = coupon;
            postdata['sku'] = sku;
            postdata['remarks'] = remarks;
            postdata['pay_type'] = pay_type;
            postdata['single_price'] = single_price;
            postdata['group_price'] = group_price;

            var alldata=1;
            var falselog="";
            $.each(postdata, function (key, value) {
                if(value=="" && key!='coupon' && key!='remarks' && key!='keyword'&& key!='sku' ){
                    alldata=0;
                    falselog=key;
                    return false;
                }
            });

            if(!alldata){
                layer.msg("缺少参数");
                on_request = false;
                $("input[name='"+falselog+"']").focus();
                return;
            }

            if(number>20){
                var result= confirm("单量超过20 请确认是否正确");
                if(!result){
                    return;;
                }

            }
            if(each_single>20){
                var result=  confirm("单量超过20 请确认是否正确");
                if(!result){
                    return;;
                }
            }
            postdata['pic'] = picpath;


            on_request = true;
            $.post(url, postdata, function (data) {
                on_request = false;
                if(data.code==0){
                    layer.msg("任务发布成功")
                    window.location.href="<?php echo base_url() ?>"+'/business/pddtasklist' ;
                } else{
                    layer.msg(data.msg)
                }
            },"json");
        }


        $("input[name='each_single']").bind("change",setgold);
        $("input[name='pay_price']").bind("change",setgold);
        $("input[name='number']").bind("change",setgold);



        function setgold(){
            var price=$("input[name='pay_price']").val();
            var number=$("input[name='number']").val();
            var each_single=$("input[name='each_single']").val();
            var needmoney=price*number*each_single;
            if(needmoney<=0){
                return;
            }
            needmoney=formatterNumber(needmoney);
            $(".needmoney").text(needmoney);
            var url = "<?php echo base_url(); ?>/Business/getgoldbymoney/2";
            var postdata = {};
            postdata['needmoney'] = needmoney;

            $.post(url, postdata, function (data) {
                on_request = false;
                $(".needgold").text(data.allgold);
            },"json");

        }














    </script>








    <div class="foods">
        <ul>
            版权所有@2015.
        </ul>
        <dl>
            <a href="" title="返回头部" class="am-icon-btn am-icon-arrow-up"></a>
        </dl>
    </div>




</div>

</div>




</div>


<!--<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>-->
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="<?php echo base_url() . 'public/business/'; ?>assets/js/polyfill/rem.min.js"></script>
<script src="<?php echo base_url() . 'public/business/'; ?>assets/js/polyfill/respond.min.js"></script>
<script src="<?php echo base_url() . 'public/business/'; ?>assets/js/amazeui.legacy.js"></script>


<!--[if (gte IE 9)|!(IE)]><!-->
<script src="<?php echo base_url() . 'public/business/'; ?>assets/js/amazeui.min.js"></script>
<!--<![endif]-->



</body>
</html>